﻿using System;
using System.Globalization;
using System.Transactions;

namespace Sherwood.Content
{
    public static class ExtensionMethods
    {
        public static CultureInfo GetCultureInfo(this IRecord record)
        {
            if (record == null) throw new ArgumentNullException("record");
            try
            {
                return string.IsNullOrEmpty(record.CultureName) ? null : CultureInfo.GetCultureInfo(record.CultureName);
            }
            catch
            {
                return null;
            }
        }

        public static IDataSessionScope CreateScope(this IDataSessionProvider provider)
        {
            return provider.CreateScope(IsolationLevel.Unspecified);
        }
    }
}